function [omega, phi, n_C] = correct_rob_movement(r_f, p_f, eta_n, n_C, target, r, v, omega)

global workspace_data d_max_pos_m_point c_acc_seek timestep obst_det

path = workspace_data.traj_m;
phi = 0;
% check if there's no obstacle (obstacle avoidance has priority)
if ~obst_det
        
    % verification of current route (distance to m-point bigger than limit?)
    if abs((r_f - path(p_f,:))*eta_n') > d_max_pos_m_point

        % determination of correction angle
        a_seek = ((path(target,:) - r) - v)* c_acc_seek;
        v_seek = timestep*a_seek;
        
        vl = v + v_seek;
        phi = atan2((v(1)*vl(2) - vl(1)*v(2)),(v(1)*vl(1) + v(2)*vl(2)));

        % correction of velocity
        omega = radtodeg(phi)/timestep;     
        
        % total number of corrections
        n_C = n_C + 1;          

    else   
%         a_seek = [ 0 0 ];
        phi   = 0;            
        omega = 0;  

    end 
    
end
end

